<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>按钮1</button>
<button>按钮2</button>
<button>按钮3</button>

<script>
   var btns= document.querySelectorAll('button');



   //bink 改变定时器内部this的指向
   /*for (let i = 0; i <btns.length; i++) {
       btns[i].onclick=function (){
           this.disabled=true;
           setTimeout(function (){
              this.disabled=false;
           }.bind(this),2000)

       }
   }*/


   //方法二
   for (let i = 0; i <btns.length; i++) {
       btns[i].onclick=function (){
           this.disabled=true;
           let that=this;
           setTimeout(function (){
               that.disabled=false;
           },2000)

       }
   }

</script>

</body>
</html>